﻿namespace SERFLITEMAX20.Core
{
    using SERFLITEMAX20;
    using SERFLITEMAX20.DataObjects;
    using System;
    using System.Collections;
    using System.Collections.Generic;
    using System.IO;
    using System.Runtime.CompilerServices;
    using System.Runtime.InteropServices;
    using System.Threading;
    using System.Xml;

    [ClassInterface(ClassInterfaceType.AutoDual), ComVisible(true)]
    public class Main
    {
        internal SERFLITEMAX20.DataObjects.Area area = null;
        internal bool bobberValid = false;
        private bool hasStarted = false;
        internal bool hostilesInLOSAndAttackable = false;
        private int interval = 100;
        internal bool mActive = false;
        internal SERFLITEMAX20.DataObjects.Map map = null;
        private MemoryReader memory = null;
        internal Hashtable objsById;
        internal Hashtable objsByPtr;
        private const float PI2 = 6.283185f;
        private bool terminateUpdateThread = false;
        private const float TurnSpeed = 0.00328125f;
        private Thread updateThread;
        private static readonly bool usepointer = false;
        internal Hashtable xmlObjectCache = new Hashtable();

        public delegate void OnAddWatchEvent(int pBaseptr, int pOffset, string pType);
        public OnAddWatchEvent AddWatchEvent;

        public delegate void OnUpdateEvent(Main sender);
        public OnUpdateEvent AfterUpdate;

        public delegate void OnExceptionEvent(Exception ex);
        public OnExceptionEvent ExceptionEvent;

        public Main()
        {
            this.Initialize();
        }

        public string CalcDirection(float current, float next)
        {
            string str = "";
            float num = 6.25f;
            float num2 = num / 2f;
            float num3 = Math.Max(current, next);
            float num4 = Math.Min(current, next);
            float num5 = num3 - num4;
            if (num5 > num2)
            {
                if (current != next)
                {
                    if (current == num4)
                    {
                        return "LEFT";
                    }
                    if (current == num3)
                    {
                        str = "RIGHT";
                    }
                    return str;
                }
                return "SAME";
            }
            if (current != next)
            {
                if (current == num4)
                {
                    return "RIGHT";
                }
                if (current == num3)
                {
                    str = "LEFT";
                }
                return str;
            }
            return "SAME";
        }

        public float CalcTurnAmount(float current, float next)
        {
            float num2 = 6.25f;
            float num3 = num2 / 2f;
            float num4 = Math.Max(current, next);
            float num5 = Math.Min(current, next);
            float num6 = num4 - num5;
            if (num6 > num3)
            {
                float num7 = num4 + num6;
                float num8 = 0f;
                num8 = num4 - num2;
                return (Math.Abs(num8) + num5);
            }
            return num6;
        }

        ~Main()
        {
            if (this.hasStarted)
            {
                this.Stop();
            }
        }

        public int GetDifficulty(UnitBase unit)
        {
            int[] numArray = new int[] { 
                4, 4, 5, 5, 6, 6, 7, 7, 8, 9, 10, 11, 12, 12, 12, 12, 
                12, 12, 12, 12
             };
            long num = (Globals.player.Level * 0x66666667L) >> 0x21;
            if (num >= numArray.Length)
            {
                num = numArray.Length - 1;
            }
            int num2 = unit.Level - Globals.player.Level;
            if (num2 >= 5)
            {
                return 4;
            }
            if (num2 >= 3)
            {
                return 3;
            }
            if (num2 >= -2)
            {
                return 2;
            }
            if (-num2 <= numArray[(int)((IntPtr)num)])
            {
                return 1;
            }
            return 0;
        }

        public BaseObject GetObjByPtr(int ptr)
        {
            switch (this.Memory.ReadInteger(ptr + Addresses.OFFSET_OBJECT_TYPE))
            {
                case 1:
                    return null;

                case 2:
                    return null;

                case 3:
                    return new UnitObject(ptr, this);

                case 4:
                    return new PlayerObject(ptr, this);

                case 5:
                    return new SERFLITEMAX20.Core.GameObject(ptr, this);

                case 6:
                    return null;

                case 7:
                    return new CorpseObject(ptr, this);
            }
            return null;
        }

        public BaseObject GetObjByPtrFishing(int ptr)
        {
            switch (this.Memory.ReadInteger(ptr + Addresses.OFFSET_OBJECT_TYPE))
            {
                case 3:
                    return new UnitObject(ptr, this);

                case 4:
                    return new PlayerObject(ptr, this);

                case 5:
                    return new SERFLITEMAX20.Core.GameObject(ptr, this);
            }
            return null;
        }

        public float GetTurnRadian(float newRadian, bool faceAway, out bool turnRight)
        {
            float playerFacing = this.PlayerFacing;
            while (newRadian < 0f)
            {
                newRadian += 6.283185f;
            }
            while (newRadian > 6.283185f)
            {
                newRadian -= 6.283185f;
            }
            while (playerFacing < 0f)
            {
                playerFacing += 6.283185f;
            }
            while (playerFacing > 6.283185f)
            {
                playerFacing -= 6.283185f;
            }
            float num2 = newRadian - playerFacing;
            if (num2 < 0f)
            {
                num2 += 6.283185f;
            }
            float num3 = playerFacing - newRadian;
            if (num3 < 0f)
            {
                num3 += 6.283185f;
            }
            turnRight = true;
            float num4 = num3;
            if (num2 < num3)
            {
                num4 = num2;
                turnRight = false;
            }
            return num4;
        }

        public float GetTurnRadian(float x, float y, bool faceAway, out bool turnRight)
        {
            PlayerObject player = Globals.player;
            turnRight = false;
            if (player == null)
            {
                return 0f;
            }
            float newRadian = player.GetFaceRadian(x, y) + (faceAway ? 3.141593f : 0f);
            return this.GetTurnRadian(newRadian, faceAway, out turnRight);
        }

        public int GetUnitReaction(UnitBase unit1, UnitBase unit2)
        {
            int num7;
            if ((unit2 == null) || (unit1 == null))
            {
                return 0;
            }
            int num = 0;
            int unitFactionByPtr = unit1.GetUnitFactionByPtr();
            int num3 = unit2.GetUnitFactionByPtr();
            int num4 = 0;
            int num5 = 0;
            if (((unitFactionByPtr == 0) || (num3 == 0)) || (unitFactionByPtr == -1))
            {
                return 0;
            }
            num4 = this.memory.ReadInteger(unitFactionByPtr + 12);
            num5 = this.memory.ReadInteger(num3 + 20);
            if ((num4 & num5) != 0)
            {
                return 1;
            }
            int address = num3 + 0x18;
            for (num7 = 0; num7 < 4; num7++)
            {
                num = this.memory.ReadInteger(address);
                if (num == 0)
                {
                    break;
                }
                if (num == this.memory.ReadInteger(unitFactionByPtr + 4))
                {
                    return 1;
                }
                address += 4;
            }
            if ((this.memory.ReadInteger(unitFactionByPtr + 12) & this.memory.ReadInteger(num3 + 0x10)) != 0)
            {
                return 4;
            }
            address = num3 + 40;
            for (num7 = 0; num7 < 4; num7++)
            {
                if (this.memory.ReadInteger(address) == 0)
                {
                    break;
                }
                if (this.memory.ReadInteger(address) == this.memory.ReadInteger(unitFactionByPtr + 4))
                {
                    return 4;
                }
                address += 4;
            }
            if ((this.memory.ReadInteger(num3 + 12) & this.memory.ReadInteger(unitFactionByPtr + 0x10)) != 0)
            {
                return 4;
            }
            address = unitFactionByPtr + 40;
            for (num7 = 0; num7 < 4; num7++)
            {
                num = this.memory.ReadInteger(address);
                if (num == 0)
                {
                    break;
                }
                if (num == this.memory.ReadInteger(num3 + 4))
                {
                    return 4;
                }
                address += 4;
            }
            return 3;
        }

        public string GetXML()
        {
            if (Globals.player != null)
            {
                XmlDocument pDom = new XmlDocument();
                XmlElement newChild = pDom.CreateElement("Main");
                newChild.SetAttribute("areaid", this.AreaID.ToString());
                newChild.SetAttribute("mapid", this.MapID.ToString());
                newChild.SetAttribute("wowactive", this.memory.WowActive().ToString());
                XmlElement xMLElement = Globals.player.GetXMLElement(pDom, "player");
                newChild.AppendChild(xMLElement);
                foreach (BaseObject obj2 in this.Objects.Values)
                {
                    if (Globals.player == obj2)
                    {
                        continue;
                    }
                    if (obj2 is SERFLITEMAX20.Core.GameObject)
                    {
                        SERFLITEMAX20.Core.GameObject obj3 = (SERFLITEMAX20.Core.GameObject)obj2;
                        if (obj3.TypeId == GameobjectTypes.CHAIR)
                        {
                            continue;
                        }
                    }
                    XmlElement baseXMLElement = obj2.GetXMLElement(pDom);
                    if (this.xmlObjectCache.Contains(obj2.Guid))
                    {
                        if (baseXMLElement.OuterXml == ((string)this.xmlObjectCache[obj2.Guid]))
                        {
                            baseXMLElement = obj2.GetBaseXMLElement(pDom);
                            baseXMLElement.SetAttribute("HasChanged", "False");
                        }
                        else
                        {
                            baseXMLElement.SetAttribute("HasChanged", "True");
                            this.xmlObjectCache[obj2.Guid] = baseXMLElement.OuterXml;
                        }
                    }
                    else
                    {
                        baseXMLElement.SetAttribute("HasChanged", "True");
                        this.xmlObjectCache[obj2.Guid] = baseXMLElement.OuterXml;
                    }
                    newChild.AppendChild(baseXMLElement);
                }
                pDom.AppendChild(newChild);
                List<long> list = new List<long>();
                foreach (long num in this.xmlObjectCache.Keys)
                {
                    if (!this.Objects.ContainsKey(num))
                    {
                        list.Add(num);
                    }
                }
                foreach (long num in list)
                {
                    this.xmlObjectCache.Remove(num);
                }
                return pDom.InnerXml;
            }
            return "";
        }

        private void Initialize()
        {
            this.objsById = new Hashtable();
            this.objsByPtr = new Hashtable();
            this.memory = new MemoryReader();
            bool flag = this.memory.TweakMyACL();
        }

        public void RaiseAddWatchEvent(int pBaseptr, int pOffset, string pType)
        {
            if (this.AddWatchEvent != null)
            {
                this.AddWatchEvent(pBaseptr, pOffset, pType);
            }
        }

        public void RaiseExceptionEvent(Exception ex)
        {
            if (this.ExceptionEvent != null)
            {
                this.ExceptionEvent(ex);
            }
        }

        public bool Start()
        {
            if (this.hasStarted)
            {
                this.Stop();
            }
            if (this.memory.IsOpen)
            {
                this.memory.Close();
            }
            this.memory.OpenProcessByName("WoW");
            this.terminateUpdateThread = false;
            if (this.objsByPtr != null)
            {
                foreach (BaseObject obj2 in this.objsByPtr.Values)
                {
                    obj2.invalid = true;
                }
            }
            this.objsByPtr.Clear();
            this.objsById.Clear();
            Globals.playerNames = new PlayerNames(this);
            this.updateThread = new Thread(new ThreadStart(this.updateProc));
            this.updateThread.Start();
            this.hasStarted = true;
            return true;
        }

        public bool StartFishing()
        {
            if (this.hasStarted)
            {
                this.Stop();
            }
            if (this.memory.IsOpen)
            {
                this.memory.Close();
            }
            this.memory.OpenProcessByName("WoW");
            this.terminateUpdateThread = false;
            if (this.objsByPtr != null)
            {
                foreach (BaseObject obj2 in this.objsByPtr.Values)
                {
                    obj2.invalid = true;
                }
            }
            this.objsByPtr.Clear();
            this.objsById.Clear();
            Globals.playerNames = new PlayerNames(this);
            this.updateThread = new Thread(new ThreadStart(this.updateProcFishing));
            this.updateThread.Start();
            this.hasStarted = true;
            return true;
        }

        public bool StartSearch()
        {
            if (this.hasStarted)
            {
                this.Stop();
            }
            if (this.memory.IsOpen)
            {
                this.memory.Close();
            }
            this.memory.OpenProcessByName("WoW");
            this.terminateUpdateThread = false;
            this.hasStarted = true;
            return true;
        }

        public void Stop()
        {
            if (this.hasStarted)
            {
                this.terminateUpdateThread = true;
                this.updateThread.Interrupt();
                this.updateThread.Join();
                this.updateThread.Abort();
                this.updateThread = null;
                if (this.memory.IsOpen)
                {
                    this.memory.Close();
                }
                this.hasStarted = false;
            }
        }

        public void UpdateAreaInfo()
        {
            int key = this.memory.ReadInteger(Addresses.STATIC_AreaID);
            if (((this.area == null) || (this.map == null)) || (this.area.id != key))
            {
                try
                {
                    if (Support.areaList.ContainsKey(key))
                    {
                        this.area = Support.areaList[key];
                    }
                    else
                    {
                        this.area = null;
                    }
                    if (this.area != null)
                    {
                        if (((this.map == null) || (this.map.id != this.area.mapid)) && Support.mapList.ContainsKey(this.area.mapid))
                        {
                            this.map = Support.mapList[this.area.mapid];
                        }
                        else
                        {
                            this.map = null;
                        }
                    }
                    else
                    {
                        this.map = null;
                    }
                }
                catch
                {
                }
            }
        }

        public void UpdatePlayerTable()
        {
        }

        private void updateProc()
        {
            while (!this.terminateUpdateThread)
            {
                Hashtable hashtable = new Hashtable();
                Hashtable hashtable2 = new Hashtable();
                if (this.memory.IsOpen)
                {
                    long pGuid = 0L;
                    int num2 = this.memory.GetBaseAddrFromTLS(Addresses.STATIC_TLS_SLOT, Addresses.OFFSET_TLS_curMgr, Addresses.OFFSET_playerID, out pGuid);
                    int num3 = Addresses.OFFSET_s_curMgr_NextObject;
                    int key = num2 + (Addresses.OFFSET_s_curMgr_FirstObject - num3);
                    int num5 = 0;
                    int num6 = 0;
                    Globals.playerNames.UpdateAll();
                    while ((!this.terminateUpdateThread && (num2 > 0)) && this.memory.IsOpen)
                    {
                        key = this.memory.ReadInteger(key + num3);
                        if ((((key & 1) != 0) || (key == 0)) || (key == 0x1c))
                        {
                            break;
                        }
                        BaseObject objByPtr = null;
                        if (this.objsByPtr.Contains(key))
                        {
                            objByPtr = (BaseObject)this.objsByPtr[key];
                            if (!objByPtr.Update())
                            {
                                objByPtr = null;
                            }
                        }
                        if (objByPtr == null)
                        {
                            objByPtr = this.GetObjByPtr(key);
                            if (objByPtr == null)
                            {
                                continue;
                            }
                            objByPtr.Update();
                        }
                        if (objByPtr.Guid == pGuid)
                        {
                            Globals.player = (PlayerObject)objByPtr;
                        }
                        if (!hashtable2.Contains(key))
                        {
                            hashtable2.Add(key, objByPtr);
                        }
                        if (!hashtable.Contains(objByPtr.Guid))
                        {
                            hashtable.Add(objByPtr.Guid, objByPtr);
                        }
                        if (num5 == key)
                        {
                            num6++;
                            if (num6 == 5)
                            {
                                break;
                            }
                        }
                        else
                        {
                            num5 = key;
                            num6 = 0;
                        }
                        if ((Globals.player != null) && (Globals.player.Guid != pGuid))
                        {
                            Globals.player = null;
                        }
                    }
                    this.objsByPtr = hashtable2;
                    this.objsById = hashtable;
                }
                if (this.AfterUpdate != null)
                {
                    this.AfterUpdate(this);
                }
                try
                {
                    Thread.Sleep(this.interval);
                }
                catch
                {
                    break;
                }
            }
        }

        private void updateProcFishing()
        {
            while (!this.terminateUpdateThread)
            {
                Hashtable hashtable = new Hashtable();
                Hashtable hashtable2 = new Hashtable();
                bool flag = false;
                if (this.memory.IsOpen)
                {
                    long pGuid = 0L;
                    int num2 = this.memory.GetBaseAddrFromTLS(Addresses.STATIC_TLS_SLOT, Addresses.OFFSET_TLS_curMgr, Addresses.OFFSET_playerID, out pGuid);
                    int num3 = Addresses.OFFSET_s_curMgr_NextObject;
                    int key = num2 + (Addresses.OFFSET_s_curMgr_FirstObject - num3);
                    int num5 = 0;
                    int num6 = 0;
                    Globals.playerNames.UpdateAll();
                    while ((!this.terminateUpdateThread && (num2 > 0)) && this.memory.IsOpen)
                    {
                        key = this.memory.ReadInteger(key + num3);
                        if ((((key & 1) != 0) || (key == 0)) || (key == 0x1c))
                        {
                            break;
                        }
                        BaseObject objByPtrFishing = null;
                        if (this.objsByPtr.Contains(key))
                        {
                            objByPtrFishing = (BaseObject)this.objsByPtr[key];
                            if (!objByPtrFishing.Update())
                            {
                                objByPtrFishing = null;
                            }
                        }
                        if (objByPtrFishing == null)
                        {
                            objByPtrFishing = this.GetObjByPtrFishing(key);
                            if (objByPtrFishing == null)
                            {
                                continue;
                            }
                            objByPtrFishing.Update();
                        }
                        if ((objByPtrFishing is SERFLITEMAX20.Core.GameObject) || (objByPtrFishing is UnitBase))
                        {
                            if (objByPtrFishing is SERFLITEMAX20.Core.GameObject)
                            {
                                SERFLITEMAX20.Core.GameObject obj3 = (SERFLITEMAX20.Core.GameObject)objByPtrFishing;
                                if ((obj3.TypeId == GameobjectTypes.FISHINGNODE) && (obj3.CreatedBy == pGuid))
                                {
                                    Globals.bobber = obj3;
                                    this.bobberValid = true;
                                }
                            }
                            if (objByPtrFishing.Guid == pGuid)
                            {
                                Globals.player = (PlayerObject)objByPtrFishing;
                            }
                            if (!hashtable2.Contains(key))
                            {
                                hashtable2.Add(key, objByPtrFishing);
                            }
                            if (!hashtable.Contains(objByPtrFishing.Guid))
                            {
                                hashtable.Add(objByPtrFishing.Guid, objByPtrFishing);
                            }
                        }
                        if ((objByPtrFishing is UnitObject) && !flag)
                        {
                            UnitObject obj4 = (UnitObject)objByPtrFishing;
                            if ((obj4.UnitReactionToPlayer == 1) && (obj4.Health > 0))
                            {
                                bool turnRight = false;
                                if (this.GetTurnRadian(obj4.X, obj4.Y, false, out turnRight) < 0.9f)
                                {
                                    flag = true;
                                }
                            }
                        }
                        if (num5 == key)
                        {
                            num6++;
                            if (num6 == 5)
                            {
                                break;
                            }
                        }
                        else
                        {
                            num5 = key;
                            num6 = 0;
                        }
                        if ((Globals.bobber != null) && !this.BobberValid)
                        {
                            this.bobberValid = false;
                            Globals.bobber = null;
                        }
                        if ((Globals.player != null) && (Globals.player.Guid != pGuid))
                        {
                            Globals.player = null;
                        }
                    }
                    this.hostilesInLOSAndAttackable = flag;
                    this.objsByPtr = hashtable2;
                    this.objsById = hashtable;
                }
                if (this.AfterUpdate != null)
                {
                    this.AfterUpdate(this);
                }
                try
                {
                    Thread.Sleep(this.interval);
                }
                catch
                {
                    break;
                }
            }
        }

        public SERFLITEMAX20.DataObjects.Area Area
        {
            get
            {
                this.UpdateAreaInfo();
                return this.area;
            }
        }

        public int AreaID
        {
            get
            {
                this.UpdateAreaInfo();
                if (this.area != null)
                {
                    return this.area.id;
                }
                return 0;
            }
        }

        public bool AttackTarget
        {
            get
            {
                if (!this.TargetHasLife)
                {
                    return false;
                }
                BaseObject target = this.Target;
                if (target == null)
                {
                    return false;
                }
                return ((target is UnitBase) && ((((UnitBase)target).UnitReactionToPlayer == 1) || (((UnitBase)target).UnitReactionToPlayer == 2)));
            }
        }

        public SERFLITEMAX20.Core.GameObject Bobber
        {
            get
            {
                return Globals.bobber;
            }
        }

        public long BobberGuid
        {
            get
            {
                try
                {
                    if ((((this.Player != null) && (this.Player.Target != null)) && (this.Player.Target is SERFLITEMAX20.Core.GameObject)) && (((SERFLITEMAX20.Core.GameObject)this.Player.Target).TypeId == GameobjectTypes.FISHINGNODE))
                    {
                        return this.Player.TargetGUID;
                    }
                }
                catch
                {
                }
                return 0L;
            }
        }

        public bool BobberValid
        {
            get
            {
                return this.bobberValid;
            }
        }

        public bool HasStarted
        {
            get
            {
                return this.hasStarted;
            }
        }

        public bool HasTarget
        {
            get
            {
                if (this.Target == null)
                {
                    return false;
                }
                return true;
            }
        }

        public bool HostilesInLOSAndAttackable
        {
            get
            {
                return this.hostilesInLOSAndAttackable;
            }
        }

        public int Interval
        {
            get
            {
                return this.interval;
            }
            set
            {
                this.interval = value;
            }
        }

        public SERFLITEMAX20.DataObjects.Map Map
        {
            get
            {
                this.UpdateAreaInfo();
                return this.map;
            }
        }

        public int MapID
        {
            get
            {
                this.UpdateAreaInfo();
                if (this.map != null)
                {
                    return this.map.id;
                }
                return 0;
            }
        }

        public MemoryReader Memory
        {
            get
            {
                return this.memory;
            }
        }

        public Hashtable Objects
        {
            get
            {
                return this.objsById;
            }
        }

        public PlayerObject Player
        {
            get
            {
                return Globals.player;
            }
        }

        public float PlayerFacing
        {
            get
            {
                if (usepointer)
                {
                    return this.Memory.ReadFloat(Addresses.STATIC_PLAYER_ROT);
                }
                lock (Globals.player)
                {
                    if (Globals.player == null)
                    {
                        return 0f;
                    }
                    return Globals.player.Facing;
                }
            }
        }

        public float PlayerX
        {
            get
            {
                if (usepointer)
                {
                    return this.Memory.ReadFloat(Addresses.STATIC_PLAYER_X);
                }
                lock (Globals.player)
                {
                    if (Globals.player == null)
                    {
                        return 0f;
                    }
                    return Globals.player.X;
                }
            }
        }

        public float PlayerY
        {
            get
            {
                if (usepointer)
                {
                    return this.Memory.ReadFloat(Addresses.STATIC_PLAYER_X + 4);
                }
                lock (Globals.player)
                {
                    if (Globals.player == null)
                    {
                        return 0f;
                    }
                    return Globals.player.Y;
                }
            }
        }

        public float PlayerZ
        {
            get
            {
                if (usepointer)
                {
                    return this.Memory.ReadFloat(Addresses.STATIC_PLAYER_X + 8);
                }
                lock (Globals.player)
                {
                    if (Globals.player == null)
                    {
                        return 0f;
                    }
                    return Globals.player.Z;
                }
            }
        }

        public bool TakeScreenShot
        {
            get
            {
                if (File.Exists(@"C:\Documents and Settings\All Users\Documents\screen.txt"))
                {
                    File.Delete(@"C:\Documents and Settings\All Users\Documents\screen.txt");
                    return true;
                }
                return false;
            }
        }

        public BaseObject Target
        {
            get
            {
                if (this.Player == null)
                {
                    return null;
                }
                return this.Player.Target;
            }
        }

        public float TargetDistance
        {
            get
            {
                BaseObject target = this.Target;
                PlayerObject player = Globals.player;
                if (target != null)
                {
                    return target.GetDistance(player);
                }
                return 0f;
            }
        }

        public bool TargetHasLife
        {
            get
            {
                BaseObject target = this.Target;
                if (target == null)
                {
                    return false;
                }
                return ((target is UnitBase) && (((UnitBase)target).Health > 0));
            }
        }

        public int TargetHealth
        {
            get
            {
                BaseObject target = this.Target;
                if ((target != null) && (target is UnitBase))
                {
                    return ((UnitBase)target).Health;
                }
                return 0;
            }
        }

        public int TargetReactionToPlayer
        {
            get
            {
                if (this.TargetHasLife)
                {
                    BaseObject target = this.Target;
                    if (target == null)
                    {
                        return -1;
                    }
                    if (target is UnitBase)
                    {
                        return ((UnitBase)target).UnitReactionToPlayer;
                    }
                }
                return -1;
            }
        }

        public float TargetTurnAmount
        {
            get
            {
                BaseObject target = this.Target;
                if (target != null)
                {
                    bool turnRight = false;
                    return this.GetTurnRadian(target.X, target.Y, false, out turnRight);
                }
                return 0f;
            }
        }

        public float TargetX
        {
            get
            {
                float x = 0f;
                BaseObject target = this.Target;
                if (target != null)
                {
                    x = target.X;
                }
                return x;
            }
        }

        public float TargetY
        {
            get
            {
                float y = 0f;
                BaseObject target = this.Target;
                if (target != null)
                {
                    y = target.Y;
                }
                return y;
            }
        }

        public float TargetZ
        {
            get
            {
                float z = 0f;
                BaseObject target = this.Target;
                if (target != null)
                {
                    z = target.Z;
                }
                return z;
            }
        }
    }
}

